package com.kitty.game.role;

import com.kitty.common.utils.ConcurrentHashSet;
import com.kitty.common.utils.SpringUtils;
import com.kitty.game.enter.RespDisappear;
import com.kitty.game.equip.message.RespNotifyMiscEx;
import com.kitty.game.role.message.Req54120;
import com.kitty.game.role.message.ReqGeneralNotify;
import com.kitty.game.role.model.Role;
import com.kitty.game.team.message.RespMsg;
import com.kitty.game.utils.Const;
import com.kitty.mina.annotation.RequestMapping;
import com.kitty.mina.cache.SessionCache;
import com.kitty.mina.cache.SessionUtils;
import com.kitty.mina.message.MessagePusher;
import org.apache.mina.core.session.IoSession;
import org.springframework.stereotype.Controller;

import java.io.Serializable;
import java.util.Map;

@Controller
public class Controller54120 {

    @RequestMapping
    public void generalNotify(IoSession session, Req54120 req54120) {
        Role role = SessionUtils.getRoleBySession(session);
        int mapId = role.getPos().getMapId();
        if (SpringUtils.getMapService().isInMap(role, 38004)) {
            MessagePusher.pushMessage(role, new RespNotifyMiscEx("当前地图不允许点击屏蔽按钮！"));
            return;
        }
        if (SpringUtils.getMapService().isInMap(role, 60007)) {
            MessagePusher.pushMessage(role, new RespNotifyMiscEx("当前地图不允许点击屏蔽按钮！"));
            return;
        }
        ConcurrentHashSet<Integer> roleIds = SessionCache.MAPID_ROLEIDS.get(mapId);
        for (Integer roleId : roleIds) {
            Role onlineRole = SpringUtils.getRoleService().getOnlinePlayer(roleId);
            if(Math.abs(onlineRole.getPos().getX()-role.getPos().getX())>20 || Math.abs(onlineRole.getPos().getY()-role.getPos().getY())>20){
                continue;
            }
            RespDisappear respDisappear = new RespDisappear();
            respDisappear.setId(onlineRole.getRoleId());
            MessagePusher.pushMessage(role, respDisappear);
        }
        //MessagePusher.pushMessage(session, new RespMsg("#Y已为你屏蔽周围玩家，如果想再次看到他们，请切换地图"));
        MessagePusher.pushMessage(role,new RespNotifyMiscEx("#Y已为你屏蔽周围玩家，如果想再次看到他们，请切换地图或者稍微大范围移动一下"));

    }
}
